package ext.sim.forces;

import ext.sim.Body;
import java.util.ArrayList;
import math.vec3;
import static math.vec3.*;

public class ForceUniformGrav implements Force
{
    
    private ArrayList<Body> rBodies;
    
    private vec3 mDir;
    
    private double mFieldAccel;
    
    
    public ForceUniformGrav(
            ArrayList<Body> aBodies, 
            vec3 aDir, 
            double aFieldAccel)
    {
        this.rBodies = aBodies;
        this.mDir = norm(aDir);
        this.mFieldAccel = aFieldAccel;
    }
    
    
    public void apply()
    {
        for (Body b : this.rBodies)
        {
            b.mF.addmul(b.mMass * this.mFieldAccel, this.mDir);
        }
    }
    
}
